package com.yaowk.sfp.slideshow.server.service.base;

import com.yaowk.sfp.common.db.BaseServiceImpl;
import com.yaowk.sfp.slideshow.server.dao.SlideshowDao;
import java.lang.Long;
import com.yaowk.sfp.slideshow.server.entity.YkSlideshow;
import com.yaowk.sfp.slideshow.server.service.ISlideshowService;
import org.springframework.beans.factory.annotation.Autowired;
import java.lang.String;
import java.lang.Byte;
import com.yaowk.sfp.slideshow.api.model.Slideshow;

public abstract class SlideshowServiceBase extends BaseServiceImpl<Slideshow, YkSlideshow, Long> implements ISlideshowService {

	@Autowired
	private SlideshowDao dao;

	@Override protected SlideshowDao getDao() {
	return dao;
	}

	@Override
	public Slideshow entity2Model(YkSlideshow entity) {
		Slideshow model = null;
		if(isNotEmpty(entity)){
			model = new Slideshow();
			model.setId(entity.getId());
			model.setName(entity.getName());
			model.setImage(entity.getImage());
			model.setLinkUrl(entity.getLinkUrl());
			model.setContent(entity.getContent());
			model.setStatus(entity.getStatus());
			model.setSort(entity.getSort());
		}
		return model;
	}

	@Override
	public YkSlideshow model2Entity(Slideshow model) {
		YkSlideshow entity = null;
		if(isNotEmpty(model)){
			entity = new YkSlideshow();
			entity.setId(model.getId());
			entity.setName(model.getName());
			entity.setImage(model.getImage());
			entity.setLinkUrl(model.getLinkUrl());
			entity.setContent(model.getContent());
			entity.setStatus(model.getStatus());
			entity.setSort(model.getSort());
		}
		return entity;
	}

	@Override
	public YkSlideshow updateParams(Slideshow model) {
		YkSlideshow entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getName()))
			entity.setName(model.getName());
		if(isNotEmpty(model.getImage()))
			entity.setImage(model.getImage());
		if(isNotEmpty(model.getLinkUrl()))
			entity.setLinkUrl(model.getLinkUrl());
		if(isNotEmpty(model.getContent()))
			entity.setContent(model.getContent());
		if(isNotEmpty(model.getStatus()))
			entity.setStatus(model.getStatus());
		if(isNotEmpty(model.getSort()))
			entity.setSort(model.getSort());
		return entity;
	}


}